Skip to content

MDEV-39675 mariadb_upgrade utility failed when path=nonexist#5106

Merged
grooverdan merged 1 commit into
MariaDB:12.3from
grooverdan:MDEV-39675
May 22, 2026
Merged

MDEV-39675 mariadb_upgrade utility failed when path=nonexist#5106
grooverdan merged 1 commit into
MariaDB:12.3from
grooverdan:MDEV-39675

Conversation

@grooverdan
Copy link
Copy Markdown
Member

The upgrade SQL assumes the functions will resolve.

With a non-default path this isn't true and results in:

ERROR 1305 (42000) at line 3211: FUNCTION extract_schema_from_file_name does not exist

Resolve by setting PATH = 'CURRENT_SCHEMA' for the upgrade.

Idea thanks to Sergei Golubchik

@grooverdan grooverdan requested a review from vuvova May 21, 2026 08:48
@grooverdan grooverdan added the MariaDB Foundation Pull requests created by MariaDB Foundation label May 21, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses MDEV-39675 by ensuring the mariadb_upgrade utility handles non-existent paths correctly. It introduces a regression test and updates the system tables fix script. Reviewer feedback suggests using the assignment operator for consistency in SQL statements and fixing a typo in the test case.

Comment thread scripts/mariadb_system_tables_fix.sql
Comment thread mysql-test/main/mysql_upgrade.test Outdated
--echo #

set @old_path=@@global.path;
set global path='non-existant';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a minor typo in the string 'non-existant'. It should be 'non-existent'. Although this is a test value, correcting it improves the overall quality of the test suite. Note that the corresponding .result file should also be updated to avoid a test failure.

set global path='non-existent';

Comment thread mysql-test/main/mysql_upgrade.result Outdated
# MDEV-39675 mariadb_upgrade utility failed when path=nonexist
#
set @old_path=@@global.path;
set global path='non-existant';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Correcting the typo 'non-existant' to 'non-existent' to maintain consistency with the suggested change in the .test file.

set global path='non-existent';

@gengtianuiowa
Copy link
Copy Markdown
Contributor

I have one concern for adding set path 'CURRENT_SCHEMA';.

Is there any use case when users use mariadb_upgrade from 12.3+ to upgrade a server below 12.3?

In this case, PATH variable won't exist in the server. This line will fail.

To be more safe, is it better to just add sys. before the function call?

@vuvova
Copy link
Copy Markdown
Member

vuvova commented May 21, 2026

@gengtianuiowa , I think either will work. When one downgrades from 12.3 to 11.8 and runs mariadb-upgrade it will be mariadb-upgrade from 11.8 that does not have SET PATH statement

Comment thread scripts/mariadb_system_tables_fix.sql
set @old_path=@@global.path;
set global path='non-existant';

--exec $MYSQL_UPGRADE --force --silent 2>&1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure, mariadb-upgrade was run and in particular has run that problematic code that failed before? There is nothing in the .result file to prove it

I'd suggest to make some innocuous change in the sys schema that mariadb-upgrade would correct and verify that it was corrected

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, without the script SQL change the mariadb-upgrade returns 1 and fails.

Sure, can do sys schema change in test.

@gengtianuiowa
Copy link
Copy Markdown
Contributor

@gengtianuiowa , I think either will work. When one downgrades from 12.3 to 11.8 and runs mariadb-upgrade it will be mariadb-upgrade from 11.8 that does not have SET PATH statement

Understood. Sounds like we always run mariadb-upgrade utility on the target version.

I would still suggest using sys. if it is easy to implement, in case the PATH variable has any issue in the new major and we have to revert this new feature. We will also need to change here together. Even though we don't see any reason to revert for now, it's always good to prepare for risk beforehand.

The upgrade SQL assumes the functions will resolve.

With a non-default path this isn't true and results in:

ERROR 1305 (42000) at line 3211: FUNCTION extract_schema_from_file_name does not exist

Resolve by setting PATH = 'CURRENT_SCHEMA' for the upgrade.

Idea thanks to Sergei Golubchik
@grooverdan
Copy link
Copy Markdown
Member Author

I would still suggest using sys. if it is easy to implement, in case the PATH variable has any issue in the new major and we have to revert this new feature. We will also need to change here together. Even though we don't see any reason to revert for now, it's always good to prepare for risk beforehand.

The place where this is added the current database is mysql and it later changes to sys. So this is keeping it compatible for function etc that could exist or be added in mysql.

I also found a extract_schema_from_file_name usage in the PS. It appears that within a view the current path is ignored.

If there's a revert for a reason, with the mysql_upgrade test now using the PATH feature, the CI will fail on the revert.

Thanks for taking the time for a comment. They where good questions that needed to be considered.

@grooverdan grooverdan enabled auto-merge (rebase) May 22, 2026 01:05
@grooverdan grooverdan merged commit 66b3c67 into MariaDB:12.3 May 22, 2026
16 of 19 checks passed
@grooverdan grooverdan deleted the MDEV-39675 branch May 22, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

3 participants